home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / ispell40.lha / ispell-4.0 / mapcase.c < prev    next >
C/C++ Source or Header  |  1993-04-15  |  2KB  |  76 lines

  1. /* Copyright (C) 1990, 1993 Free Software Foundation, Inc.
  2.  
  3.    This file is part of GNU ISPELL.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19.  
  20. /* initialize mapcase array
  21.  
  22.    this array has two jobs: to distingush between "letters" (characters
  23.    that can be parts of words) and to convert upper case to lower case
  24.    when that makes sense.  The functions in 'ctype' would be good enough,
  25.    except that now we want to handle international characters */
  26.  
  27. #include <stdio.h>
  28. #include <ctype.h>
  29.  
  30. short mapcase[256];
  31.  
  32. mapcaseinit ()
  33. {
  34.   static firsttime = 1;
  35.   int i;
  36.  
  37.   if (firsttime == 0)
  38.     return;
  39.  
  40.   firsttime = 0;
  41.  
  42.   /* map upper case to lower case */
  43.   for (i = 'A'; i <= 'Z'; i++)
  44.     mapcase[i] = i - 'A' + 'a';
  45.  
  46.   /* map lower case to itself */
  47.   for (i = 'a'; i <= 'z'; i++)
  48.     mapcase[i] = i;
  49.  
  50.   /* add other normal ascii characters that should be considered
  51.      * letters here.  You might want '-' or '_'
  52.      */
  53.   mapcase['\''] = '\'';
  54.  
  55.   /* map all high bit set characters to themselves - they
  56.      * wont normally appear, and if they do, they probably represent
  57.      * characters with accent marks
  58.      */
  59.   for (i = 0x80; i < 0x100; i++)
  60.     mapcase[i] = i;
  61.  
  62.   /*
  63.      * now map upper case accented characters to
  64.      * lower case equivalents
  65.      */
  66.   /* IBM-PC */
  67.   mapcase[0x80] = 0x87;        /* c cedialla */
  68.   mapcase[0x8e] = 0x84;        /* a umlaut */
  69.   mapcase[0x8f] = 0x86;        /* a with circle */
  70.   mapcase[0x90] = 0x82;        /* e acute */
  71.   mapcase[0x92] = 0x91;        /* ae ligaturrre */
  72.   mapcase[0x99] = 0x94;        /* o umlaut */
  73.   mapcase[0x9a] = 0x81;        /* u umlaut */
  74.   mapcase[0xa5] = 0xa4;        /* n tilde */
  75. }
  76.